<link href="${rc.getContextPath()}/static/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet">

<div class="pageContent" style="padding: 5px">
    <input id="menuCode" type="hidden">
    <div class="per-docContact fn-pos-rel">
<div class="fn-left fn-pos-rel">
<div class="per-docContact-tab">
</div>
    <div class="contactList">
        <div id="left" style="width: 100%;height: 100%;overflow: auto;">
            <ul id="tree" class="tree treeFolder treeCheck expand" oncheck="oncheck">
                <#list treeList as tree>
                <li><a tvalue="${tree.organizationCode}" tname="${tree.path}">${tree.organizationText}</a> <#if tree.children?? &&tree.children?size gt 0>
                    <ul><@bpTree children=tree.children />
                    </ul> </#if> </#list>
            </ul>
        </div>
    </div>
    </div>
    <div class="contactArrow"></div>

    <div layoutH="60" style="margin-right: 5px; float: right; display: block; width: 280px; overflow: auto; background: #fff">
    <div class="per-docContact-listtitle">
          <span class="fn-left"><@label key="selected.C">已选择</@label>(<span id="selected_count">0</span>)：</span>
          <span class="fn-right linkblue"><a onclick="cl()"><@label key="clear.C">清空</@label></a></span>
      </div>
    <div class="per-docContact-list">

    <div  class="contactSelected">
    <ul id="selected">

    </ul>
    </div>
    
    </div>
    </div>
    </div>
</div>

<div class="formBar">
        <ul>
            <li>
                <a id="ok" href="javascript:" class="buttonActive" onclick="cc()"><span><@label key="ok.B">确定</@label></span></a>
            
                    
                </li>
            <li>
            <div class="buttonActiveGrey">
                        <div class="buttonContent" >
                            <button class="close" type="button" ><@label key="close.B">关闭</@label></button>
                        </div>
                    </div>
            </li>
        
        </ul>
    </div>




<#macro bpTree children> <#if children?? && children?size gt 0> <#list children as child>
<li><a tvalue="${child.organizationCode}" tname="${child.path}">${child.organizationText}</a> <#if child.children?? &&child.children?size gt 0>
    <ul><@bpTree children=child.children />
    </ul> </#if> </#list> </#if> </#macro>
    
    <script type="text/javascript">
function oncheck(){    
     var id = "";
     var name="";
     var path="";
     var str = "";
     var jsonstr="";
     $('#left input[type="checkbox"]',$.pdialog.getCurrent()).not("input:checked").each(function (i, e) {
         var my_element = $('#'+e.value);
         if(my_element.length>0)
         {
             my_element.remove();
         }
     });
     var count=0, ids = new Array(), paths = new Array(), names = new Array();
     $('#left input[type="checkbox"]:checked',$.pdialog.getCurrent()).each(function (i, e) {
         var a=$("#left a[tvalue="+e.value+"]",$.pdialog.getCurrent());
         count++;
         var my_element = $('#'+e.value,$.pdialog.getCurrent());
         if(my_element.length==0)
         {
             str += "<li id="+e.value+"><span class='contactList-filephoto'></span><span class='contactName'>"+a.text()+"</span><span onclick=del('"+e.value+"') class='deleteInfo'></span></li>";
            
         }
         ids.push(e.value);
         paths.push(e.name);
         names.push(a.text());
  
     });
     jsonstr = JSON.stringify({
         id: ids.join(','),
         path:paths.join(','),
         name: names.join(',')
     });
     $("#selected",$.pdialog.getCurrent()).append(str);
     if(count>0)
         {
     $("#ok",$.pdialog.getCurrent()).attr("onclick", "$.bringBack("+jsonstr+")");
         }
     else
         {
         $("#ok",$.pdialog.getCurrent()).attr("onclick", "cc()");
         }
     $('#selected_count',$.pdialog.getCurrent()).html(count);
     initUI($("#ok",$.pdialog.getCurrent()));

}

function cc(){
    alertMsg.warn('<@label key="selectOrg.M">请勾选组织！</@label>')
}

function del(a){
    $("#"+a).remove();
    var ck=$("#left input[value='"+a+"']:checked",$.pdialog.getCurrent());
    ck.removeAttr("checked");
    var div = ck.parent();
    div.attr("class","ckbox unchecked");
    oncheck();
    
}
function cl()
{
     $('#selected li',$.pdialog.getCurrent()).each(function (i, e) {
     e.remove();
     var ck=$("#left input[value='"+e.id+"']:checked",$.pdialog.getCurrent());
        ck.removeAttr("checked");
        var div = ck.parent();
        div.attr("class","ckbox unchecked");
    
     });
    oncheck();
}




</script>